package com.mlnx.web.data.controller;


import com.mlnx.common.entity.Response;
import com.mlnx.common.entity.ResponseData;
import com.mlnx.common.form.PageForm;
import com.mlnx.data.entity.SpoInfo;
import com.mlnx.data.pojo.form.SpoInfoForm;
import com.mlnx.data.service.SpoDataService;
import com.mlnx.stream.service.DeviceBroadcastService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.shan.spring.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@Api(value = "血氧数据接口", tags = {"血氧数据接口"})
@RestController
@RequestMapping("mlnx_data/spo")
public class SpoController extends BaseController {
    @Autowired
    private SpoDataService spoDataService;
    @Autowired
    private DeviceBroadcastService deviceBroadcastService;

    @ApiOperation("新增血氧数据")
    @PostMapping (value = "/add")
    public Response addSpo(@Valid SpoInfo spoInfo) {
        deviceBroadcastService.castSpoInfo(spoInfo);
        return result();
    }

    @ApiOperation("分页获取所有血氧数据")
    @GetMapping(value = "")
    public ResponseData getAllSpos(@Valid PageForm pageForm, @Valid SpoInfoForm spoInfoForm) {

        return result(spoDataService.getAllSpos(pageForm,spoInfoForm));
    }


}
